#include "head.h"

int tcp(int* sock_fd)
{
    char ip[20] = {0};
    char port[10] = {0};
    getparameter("ip", ip);
    getparameter("port", port);

    int fd = socket(AF_INET, SOCK_STREAM, 0);


    struct sockaddr_in addr;
    addr.sin_addr.s_addr = inet_addr(ip);
    addr.sin_port = htons(atoi(port));
    addr.sin_family = AF_INET;

    if(connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
        error(1, errno, "connect");

    *sock_fd = fd;
    return 0;
}
